fix: p11prov_tls_constant_time_depadding bug corrected #438
Add this suggestion to a batch that can be applied as a single commit.
This suggestion is invalid because no changes were made to the code.
Suggestions cannot be applied while the pull request is closed.
Suggestions cannot be applied while viewing a subset of changes.
Only one suggestion per line can be applied in a batch.
Add this suggestion to a batch that can be applied as a single commit.
Applying suggestions on deleted lines is not supported.
You must change the existing code in this line in order to create a valid suggestion.
Outdated suggestions cannot be applied.
This suggestion has been applied or marked resolved.
Suggestions cannot be applied from pending reviews.
Suggestions cannot be applied on multi-line comments.
Suggestions cannot be applied while the pull request is queued to merge.
Suggestion cannot be applied right now. Please check back later.
Hi,
Today, the connection to EVIDEN’s HSM CRYPT2PAY using the Latchset provider fails when the openssl “-cipher” option (any TLS_RSA encryption) is requested (e.g. ./openssl s_client -connect 127.0.0.1:11036 -CApath /int1/pki/store/ac/crt_rehash -tls1_2 -cipher AES128-GCM-SHA256)
The problem is caused by the 'p11prov_tls_constant_time_depadding' function in the source file src/asymmetric_cipher. c, lines 274 and 289.
274: cond = constant_equal(*out_size, 2 + length);
...
289: constant_select_buf (conc, length, out, buf + 2, randbuf);
the '2' offset is a problem and corresponds to the first 2 bytes before padding removal (done by PKCS#11)
The best proof is lines 275 and 277 which compare 2 first bytes of input buffer with client version (major and minor)
Tests :
This corrected version has been tested in our testing environment and works correctly in all our use cases.
Could it be taken into account ?
Thanks